package com.qf.service;

import com.qf.mapper.UserMapper;
import com.qf.pojo.SysUsers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author fy
 * @version V1.0
 * @Project workspace
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/19 1:13
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<SysUsers> findAll() {
        List<SysUsers> list = userMapper.findUserAll();
        return list;
    }

    @Override
    public SysUsers findUserByName(String userName) {
        SysUsers user = userMapper.findUserByName(userName);
        return user;
    }

    @Override
    public Set<String> findRoleByUid(Integer uid) {
        List<String> list = userMapper.findRoleByUid(uid);
        Set<String> roleSet = new HashSet<>();
        if (list!=null){
            for (String s : list) {
                roleSet.add(s);
            }
        }

        return roleSet;
    }

    @Override
    public Set<String> findPermByUid(Integer uid) {
        List<String> list = userMapper.findPermByUid(uid);
        Set<String> permSet = new HashSet<>();
        if (list!=null){
            for (String s : list) {
                permSet.add(s);
            }

        }
        return permSet;
    }


}
